home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Utilities / PGP / source / pgp50i-b8a / src / mklang.pl < prev    next >
Encoding:
Perl Script  |  1998-01-04  |  993 b   |  48 lines

  1. #!/usr/bin/perl
  2. #
  3. #This could probably be sed, but I'm feeling lazy.
  4. #
  5.  
  6. $LANGUAGE_FILE = "language50.txt";
  7. $HEADER_FILE = "lib/ttyui/language.h";
  8.  
  9. #In the future, this should call the routine to add the pgpErr.h strings to
  10. #the bottom of the language50.txt file, here.
  11.  
  12. #Now, we want to turn the language50.txt file into lib/ttyui/language.h file.
  13.  
  14. if(open(INF, $LANGUAGE_FILE))
  15. {
  16.     if(open(OUF, ">$HEADER_FILE"))
  17.     {
  18.     print OUF "/*Automatic translation of $LANGUAGE_FILE.\n";
  19.     print OUF " *This file is created by mklang.pl.  DO NOT EDIT!\n";
  20.     print OUF " */\n\n";
  21.     print OUF "static const char *lang = \"\\\n";
  22.  
  23.     while(<INF>)
  24.     {
  25.         chop;
  26.  
  27.         #Escape any single backslashes:
  28.         s/\\/\\\\/g;
  29.  
  30.         #Escape any quotes:
  31.         s/"/\\"/g;
  32.  
  33.         print OUF "$_\\n\\" . "\n";
  34.     }
  35.     print OUF "\";\n";
  36.     close(OUF);
  37.     }
  38.     else
  39.     {
  40.     print STDERR "Unable to open $HEADER_FILE for reading!\n";
  41.     }
  42.     close(INF);
  43. }
  44. else
  45. {
  46.     print STDERR "Unable to open $LANGUAGE_FILE for reading!\n";
  47. }
  48.